package com.bristua.barcode.supplier.biz;

import com.bristua.barcode.common.util.DateUtils;
import com.bristua.barcode.common.util.SequenceUtil;
import com.bristua.barcode.supplier.dao.TQrCodeMapper;
import com.bristua.barcode.supplier.dao.TSupplierMapper;
import com.bristua.barcode.supplier.model.TQrCode;
import com.bristua.barcode.supplier.model.TSupplier;
import com.bristua.barcode.supplier.model.condition.AddSupplierParams;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;

/**
 * Created by Administrator on 2019/8/3 0003.
 */
@Service
@Transactional
public class AddSupplierBiz {

    @Resource
    private TSupplierMapper tSupplierMapper;


    public void addSupplier(AddSupplierParams addSupplierParams){
        TSupplier tSupplier = new TSupplier();
        BeanUtils.copyProperties(addSupplierParams,tSupplier);
        tSupplier.setSupplierId(SequenceUtil.nextId());
        String showDateTime = DateUtils.getShowDateTime();
        tSupplier.setCreateTime(showDateTime);
        tSupplier.setStatus(1);
        tSupplierMapper.insert(tSupplier);

//        TQrCode tQrCode = new TQrCode();
//        tQrCode.setCreateTime(showDateTime);
//        tQrCode.setQrCodeId(SequenceUtil.nextId());
//        tQrCode.setQrCodeUrl(addSupplierParams.getQrCodeUrl());
//        tQrCode.setStatus(0);
//        tQrCode.setQrCodeType(1);
//        tQrCode.setSupplierId(tSupplier.getSupplierId());
//
//        tQrCodeMapper.insert(tQrCode);
    }
}
